<template>
<h2>添加等级页面</h2>
<table border="1">
    <tr>
        <td>会员等级名称</td>
        <td>
            <input type="text" v-model="info.Rank_Name">
        </td>
    </tr>
    <tr>
        <td>会员等级状态</td>
        <td>
            <input type="radio" :value="true" v-model="info.Rank_State">启用
            <input type="radio" :value="false" v-model="info.Rank_State">禁用
        </td>
    </tr>
    <tr>
        <td>最小成长值</td>
        <td>
            <input type="text" placeholder="请输入会员最小成长值" v-model="info.Rank_MinPoint">
        </td>
    </tr>
    <tr>
        <td>最大成长值</td>
        <td>
            <input type="text" placeholder="请输入会员最大成长值" v-model="info.Rank_MaxPoint">
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="button" value="添加" class="btn btn-success" @click="SaveDate">
        </td>
    </tr>
</table>
</template>
<script setup lang="ts">

import {ref } from 'vue';
import axios from 'axios';


const info=ref({

    Rank_Name:"",
    Rank_State:true,
    Rank_MinPoint:"",
    Rank_MaxPoint:""
  
   




})


const SaveDate=()=>{

    if(info.value.Rank_Name==""){
        alert("会员等级名称不能为空");
        return;
    }

    axios.post('https://localhost:7153/api/MemberRank/AddMemberRank',info.value)
    .then(res=>{
       if(res.data>0){
        alert("会员等级添加成功");
        
       }
       else if(res.data==-1){
        alert("会员等级名称已存在");
       }
       else{
        alert("会员等级添加失败");
       }

    })



}




</script>